home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / weapons / Steel Bat.lua < prev    next >
Text File  |  2010-08-31  |  3KB  |  78 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Steel Bat
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, September 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.steelbat={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.steelbat.gfx_wpn=loadgfx("weapons/steelbat.bmp")                                    -- Weapon Image
  13. setmidhandle(cc.steelbat.gfx_wpn)
  14. cc.steelbat.sfx_attack=loadsfx("throw.ogg")                                            -- Attack Sound
  15. cc.steelbat.sfx_steel=loadsfx("buildmetal.ogg")                                        -- Steel Sound
  16.  
  17. --------------------------------------------------------------------------------
  18. -- Weapon: Steel Bat
  19. --------------------------------------------------------------------------------
  20.  
  21. cc.steelbat.id=addweapon("cc.steelbat","Steel Bat",cc.steelbat.gfx_wpn,0)            -- Add Weapon (0 uses)
  22.  
  23. function cc.steelbat.draw()                                                            -- Draw
  24.     -- Decrease Timer (used for animation)
  25.     if weapon_timer>0.0 then
  26.         weapon_timer=weapon_timer-0.5
  27.     end
  28.     -- Draw
  29.     if getplayeraction(0)==0 then
  30.         setblend(blend_alpha)
  31.         setalpha(1)
  32.         setcolor(255,255,255)
  33.         setscale(-getplayerdirection(0),1)
  34.         setrotation(getplayerrotation(0)-(90-(weapon_timer*3))*(getplayerdirection(0)))
  35.         drawimage(cc.steelbat.gfx_wpn,getplayerx(0)+getplayerdirection(0)*7,getplayery(0)+3)
  36.     end
  37.     -- HUD Crosshair
  38.     if weapon_shots==0 then
  39.         hudcrosshair(7,3)
  40.     end
  41. end
  42.  
  43. function cc.steelbat.attack(attack)                                                    -- Attack
  44.     if (weapon_shots<=0) then
  45.         if (attack==1) then
  46.             -- No more weapon switching!
  47.             useweapon(0)
  48.             playsound(cc.steelbat.sfx_attack)
  49.             weapon_shots=weapon_shots+1
  50.             -- Set timer for animation
  51.             weapon_timer=30
  52.             -- Collision
  53.             col=0
  54.             for dist=5,20,5 do
  55.                 for i=-2,2,1 do
  56.                     if col==0 then
  57.                         if collision(col5x5,getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)+(i*10)))*dist,getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)+(i*10)))*dist,0,1,0)==1 then
  58.                             if playercollision()~=0 and playercollision()~=playercurrent() then
  59.                                 playerpush(playercollision(),math.sin(math.rad(getplayerrotation(0)))*25,-math.cos(math.rad(getplayerrotation(0)))*25)
  60.                                 playerdamage(playercollision(),50)
  61.                                 playsound(sfx_splatter1)
  62.                                 playsound(cc.steelbat.sfx_steel)
  63.                                 particle(p_ring,getplayerx(playercollision()),getplayery(playercollision()))
  64.                                 particlecolor(255,0,0)
  65.                                 blood(getplayerx(playercollision()),getplayery(playercollision()))
  66.                                 col=1
  67.                                 break
  68.                             end
  69.                         end
  70.                     end
  71.                 end
  72.             end
  73.             -- End Turn
  74.             endturn()
  75.         end
  76.     end
  77. end
  78.